import Vue from 'vue'
import Router from 'vue-router'
import VideoPlayer from 'vue-video-player'

// 引入一级路由
const Index=()=> Promise.resolve(import('@/components/index'))//首页
const Initial=()=> Promise.resolve(import('@/components/initial/com/com'))//登录和注册
const Order=()=> Promise.resolve(import('@/components/order/home'))//我的全部订单
const Orderdes=()=> Promise.resolve(import('@/components/order/orderdes'))//我的全部订单-订单详情
const Evaluate=()=> Promise.resolve(import('@/components/order/evaluate'))//我的全部订单-评价编辑
const Pay=()=> Promise.resolve(import('@/components/pay/home'))//订单-订单信息
const Details=()=> Promise.resolve(import('@/components/details/home'))//商品详情
const Service=()=> Promise.resolve(import('@/components/service/home'))//我的服务



// 引入二级路由-首页
const Home=()=> Promise.resolve(import('@/components/index/home'))//首页-主页
const Classify=()=> Promise.resolve(import('@/components/index/classfy'))//首页-分页
const Cart=()=> Promise.resolve(import('@/components/index/cart'))//首页-购物车
const Me=()=> Promise.resolve(import('@/components/index/me'))//首页-我的中心

// 引入二级路由-商品
const Goods=()=> Promise.resolve(import('@/components/details/goods'))//商品-详情
const Deevaluate=()=> Promise.resolve(import('@/components/details/evaluate'))//商品-评价
const Twocode=()=> Promise.resolve(import('@/components/details/twocode'))//商品-评价
const Screen=()=> Promise.resolve(import('@/components/details/screen'))//商品-视频图片

//引入二级初始化-初始
const Login=()=> Promise.resolve(import('@/components/initial/login'))//初始-登录
const Register=()=> Promise.resolve(import('@/components/initial/register'))//初始-注册


//二级路由 -订单
const Consigneelist=()=> Promise.resolve(import('@/components/pay/Consigneelist'))//订单-收货人
const Suborder=()=> Promise.resolve(import('@/components/pay/suborder'))//订单-提交

//二级路由 -我的服务
const Coll=()=> Promise.resolve(import('@/components/service/coll'))//我的-收藏
const Setup=()=> Promise.resolve(import('@/components/service/setup'))//我的-设置



Vue.use(Router)
Vue.use(VideoPlayer)

export default new Router({
  routes: [
    {
      path: '/',
      name: 'Index',//首页
      redirect:'/home',
      component: Index,
      children:[
        {
          path:'/home',
          name:"Home",
          component:Home
        },
        {
          path:'/classify',
          name:"Classify",
          component:Classify,
          beforeEnter(to,from,next){
            console.log(this,to,from)
            to.query.lastpath=from.path;
            next()
          }
        },
        {
          path:'/cart',
          name:"Cart",
          component:Cart
        },
        {
          path:"/me",
          name:"Me",
          component:Me
        }
      ]
    },
    {
      path: '/order',
      name: 'Order',//我的全部订单
      component: Order
    },
    {
      path: '/orderdes',
      name: 'Orderdes',//我的全部订单-订单详情物流信息
      component: Orderdes 
    },
    {
      path: '/evaluate',
      name: 'Evaluate',//我的全部订单-评价编辑
      component:Evaluate
    },
    {
      path: '/pay',
      name: 'Pay',//-订单信息
      component:Pay,
      children:[
      {
        path: '/consigneelist',
        name: 'Consigneelist',//-收货人列表
        component:Consigneelist
      },
       {
        path: '/suborder',
        name: 'Suborder',//-订单提交
        component:Suborder
      },
      ]
    },
    {
      path: '/details',
      name: 'Details',//商品详情
      component:Details,
      children:[
      {
        path: '/goods',
        name: 'Goods',//-商品详情-商品
        component:Goods

      },
      {
        path: '/deevaluate',
        name: 'Deevaluate',//-商品详情-商品评价
        component:Deevaluate
      },
      {
        path: '/twocode',
        name: 'Twocode',//-商品详情-商品二维码
        component:Twocode
      },
      {
        path: '/screen',
        name: 'Screen',//-商品详情-商品视频图片
        component:Screen
      }
  
      ]
    },
    {
      path:'/initial',//初始
      name:'Initial',
      component:Initial,
      children:[
        { 
          path:'/login',
          name:'Login',
          component:Login,
          beforeEnter(to,from,next){
            console.log(from,to ,"jjjjjjjjjjjjjjjjj")
              next();
              
            }
        },
        {  
        path:'/register',
        name:'Register',
        component:Register

        },
      
      ]

    },
    {
      path:"/service",//我的服务
      name:"Service",
      component:Service,
      children:[
      {
        path:"/setup",//我的设置
        name:"setup",
        component:Setup
      },
      {
        path:"/coll",//我的收藏
        name:"Coll",
        component:Coll
      }
      
      
      ]
   
    }
   
 
  ]
})
